package com.chance.cc.crawler.development.bootstrap.yishengzhan;

import com.alibaba.fastjson.JSONObject;
import com.chance.cc.crawler.core.downloader.HttpRequestBody;
import org.apache.commons.lang.CharEncoding;

import java.util.UUID;

/**
 * @author lt
 * @version 1.0
 * @date 2021-06-23 14:42:21
 * @email okprog@sina.com
 */
public class YSZTest {

    public static void main(String[] args) {
        genRequestBody();
    }

    public static void genRequestBody(){
        JSONObject listBody = new JSONObject();
        listBody.put("content","阿里健康");
        listBody.put("start",0);
        listBody.put("limit",50);
        System.out.println(baseRequestBodyInit(listBody));
        HttpRequestBody httpRequestBody = HttpRequestBody.json(baseRequestBodyInit(listBody), CharEncoding.UTF_8);
        byte[] body = httpRequestBody.getBody();
        System.out.println(new String(body));
    }

    public static String baseRequestBodyInit(JSONObject body){
        String uuid = UUID.randomUUID().toString();
        int times = (int) (System.currentTimeMillis() / 1000);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("brand","");
        jsonObject.put("guid",uuid);
        jsonObject.put("model","");
        jsonObject.put("platform","PC");
        jsonObject.put("sysVersion","");
        jsonObject.put("time",times);
        jsonObject.put("uid",0);
        jsonObject.put("version","4.8.0");
        jsonObject.put("session","");
        jsonObject.put("body",body);
        return jsonObject.toJSONString();
    }
}
